< previous page page_186 next page >

Page 186
You can also use multiple images of the same scene to reduce random noise in the images. If the images are identical except for random noise, the real parts of the images tend to reinforce each other while the random noise tends to cancel itself out.
Finally, you can combine images to create a composite image containing features from each of the original images. Compositing techniques are used extensively in motion pictures and television to create amazing special effects.
The following sections describe these multiple image processing techniques.
Image Subtraction
To subtract two images, a program simply subtracts the color components of the images' corresponding pixels. Where the pixel values are the same, the result of the subtraction is zero, so the output pixel is black. Where the pixel values differ, the result of the subtraction is not zero. The greater the difference between the two values, the farther the result is from zero. When the program subtracts every pixel in the two images, the result highlights the differences between the images.
Because a pixel's value in one image may be darker or lighter than its value in the other, the result of the subtraction might be positive or negative. If you are interested in locating only pixels with brightness greater in the first image than in the second, you can set any negative values to zero. If you want to locate all changes to the pixels' values, you can take the absolute value of any negative results. Then larger changes in pixel values give bright colors in the result no matter which image has the brighter pixels. You can make the differences between the two images even more obvious if you enhance the contrast of the result, possibly using binary contrast enhancement.
Image subtraction has several uses. First, if a scene has changed in a subtle way, subtracting images before and after the change can make the changes obvious.
For example, to locate comets and other rapidly moving objects, astronomers compare two images of the same part of the sky taken at different times. A traditional method for comparing the images is to display them with a slide projector that quickly switches back and forth between them. If an object has moved or disappeared, the astronomer will see the object blinking on and off as the images switch. Image subtraction provides another method for finding these changes. If you subtract the two images, the result is black except in the location of the new or moving object.
You can also use image subtraction to detect edges in a single image. Shift the image by one pixel in the X and Y directions and then subtract it from the original image. The two versions of the image are the same in large regions of constant color. Where the image contains an edge between two colors, the shifted image and the original have different pixel values, so the subtraction gives a bright result.
Example program SubEdge, shown in Figure 6.11, uses this technique to enhance the edges in an image.
The following code shows how program SubEdge subtracts an image from itself. Notice that the For loops do not include the edge pixels where Y = picOriginal.ScaleHeight 1 and X = picOriginal.ScaleWidth - 1. To calculate values for those pixels, the program

 
< previous page page_186 next page >